package com.ys.basebindinggdemo.ui.home

import androidx.recyclerview.widget.LinearLayoutManager
import com.ys.basebindinggdemo.R
import com.ys.basebindinggdemo.databinding.FragmentHomeBinding
import com.ys.basebindinggdemo.navi.findNavController
import com.ys.basebindinggdemo.ui.base.BaseFragment

class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>() {

    private val adapter by lazy { HomeDeviceAdapter() }
    override fun init() {

        mBinding.apply {
            viewModel = mViewModel
            btnChange.setOnClickListener {
                findNavController().navigate(R.id.action_home_2_dashboard)
            }
            recycleViewHomeDevice.layoutManager = LinearLayoutManager(requireContext())
            recycleViewHomeDevice.adapter = adapter

        }
        mViewModel.apply {

            homeDevicesLD.observe(viewLifecycleOwner) {


                adapter.submitList(it)

            }

            _text.observe(viewLifecycleOwner) {


            }
        }

        mViewModel.homeDeviceGet()

    }


}